class MyArray<T> {
    public T[] array = (T[])new Object[10];//这里是最优的写法吗？


    public T getPos(int pos) {
        return this.array[pos];
    }

    public void setVal(int pos,T val) {
        this.array[pos] = val;
    }
}

public class Fx {
   public static void main(String[] args) {
     MyArray<Integer> myArray = new MyArray<>();//传入Integer类型形参

     myArray.setVal(0,10);
     myArray.setVal(1,12);
     int ret = myArray.getPos(1);

     System.out.println(ret);
     //myArray.setVal(2,"bit");//报错，编译器检查发现与传入类型不符
   }
}
